﻿var status = 0;
var IconA = "#fEffect/CharacterEff/1112924/0/0#";   // 黄星
var IconB = "#fEffect/CharacterEff/1112925/0/0#";  //  蓝星
var IconC = "#fEffect/CharacterEff/1112926/0/0#"; //   红星
var txt;
var sel;
var allpay;

var ca = java.util.Calendar.getInstance();
var weekday = ca.get(java.util.Calendar.DAY_OF_WEEK);//星期
var hour = ca.get(java.util.Calendar.HOUR_OF_DAY); //获得小时
var minute = ca.get(java.util.Calendar.MINUTE);//获得分钟
var second = ca.get(java.util.Calendar.SECOND); //获得秒
var time = new Date();
var sjr = time.getDay();

// 最高累积天数
var day = 365;
// 每个阶段礼包所需的充值数
var condition = new Array(2000, 4000, 6000, 8000, 10000, 12000, 14000);
// 礼包内容
var reward = new Array(
	Array(1, 100000),
    Array(2, 200000),
    Array(3, 300000),
    Array(4, 400000),
	Array(5, 500000),
	Array(6, 600000),
	Array(7, 700000),
	Array(8, 800000)
					);
function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
   
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else { 
        status--;
    }
    var curlevel = -1;

    if (status == 0) {
 rmb = parseInt(cm.getHyPay(3));
        txt = IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + "\r\n";
		txt += "\t\t#d 　- 每天福利享不停 " + cm.getServerName() + "与你狂欢 -#k\r\n";
		txt += "#L8#" + IconC + "#b  累计充值 [ #r破攻享不停#b ] 每项每日限一回 " + IconC + "#l\r\n\r\n";
		txt += "#L8#" + IconC + "#b  累计充值 [ #r破攻享不停#b ] 每项每日限一回 " + IconC + "#l\r\n\r\n";
        txt += "#L8#" + IconC + "#b  累计充值 [ #r破攻享不停#b ] 每项每日限一回 " + IconC + "#l\r\n\r\n";
        txt += "#L9#" + IconC + "#r ☆ 单击阅读详情规则  知己知彼百战百胜 ☆ " + IconC + "#l\r\n\r\n\r\n";
        txt += IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB;
        cm.sendSimpleS(txt, 2);
    } else if (status == 1) {
        switch (selection) {
            case 0:
                cm.dispose();
                cm.openNpc(9900002, 18);

                break;
            case 1:
                cm.dispose();
                cm.openNpc(9900002, 19);
                break;
            case 2:
                cm.dispose();
                cm.openNpc(9900002, 21);
                break;
            case 3:
                cm.dispose();
                cm.openNpc(9900002, 22);
                break;
            case 8:
                //paylog = cm.getllpay(day);
                txt = "您累计充值金额为： #r" + rmb + "#k 元\r\n\r\n";
                for (var i = 0; i < condition.length; i++) {
                    txt += "#b#L" + i + "#" + IconB + " 累计 #r" + condition[i] + " #b元　※ 破攻伤害值 ※";
                    if (cm.getEventCount("每天破攻礼包" + i) > 0) {
                        txt += "#r[ 已领取 ] #k" + IconB;
                        curlevel = curlevel == -1 ? i : curlevel;
                    } else {
                        txt += "#b[ 未领取 ] #k" + IconB;
                    }
                    txt += "#l\r\n";
                }
                txt += "\r\n\r\n #k";
                cm.sendSimpleS(txt, 2);
                break;
            case 9:
                txt = IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + IconB + " " + "\r\n\r\n";
                txt += "#d- 累计充值达到 [ 2000 ] 每天破攻 伤害值 + #r50W\r\n#k";
                txt += "#d- 累计充值达到 [ 4000 ] 每天破攻 伤害值 + #r50W\r\n#k";
                txt += "#d- 累计充值达到 [ 6000 ] 每天破攻 伤害值 + #r100W\r\n#k";
                txt += "#d- 累计充值达到 [ 8000 ] 每天破攻 伤害值 + #r100W\r\n#k";
                txt += "#d- 累计充值达到 [ 10000 ] 每天破攻 伤害值 + #r100W\r\n#k";
				//txt += "#d- 累计充值达到 [ 12000 ] 每天破攻 伤害值 + #r100W\r\n#k";
				//txt += "#d- 累计充值达到 [ 14000 ] 每天破攻 伤害值 + #r100W\r\n#k";
				//txt += "#d- 累计充值达到 [ 16000 ] 每天破攻 伤害值 + #r150W\r\n#k";
                cm.sendOkS(txt, 2);
                status = -1;
                break;
        }
    } else if (status == 2) {
        sel = selection;
        txt = "\t\t\t\t　#e- 破攻信息 -#n\r\n\r\n";
		 txt += "\t\t#r当前破攻礼包内 - [ #b" + reward[sel][1] + "#r ] 伤害值#k\r\n";
        /*for (var i = 0; i < reward.length; i++) {
            if (reward[i][0] == sel) {
                txt += "\t\t#r当前破攻礼包内 - [ #b" + reward[sel][1] + "#r ] 伤害值#k\r\n";
            }
        }*/
        cm.sendYesNoS(txt, 2);

    } else if (status == 3) {
        if (cm.getEventCount("每天破攻礼包" + sel) > 0) {
            cm.playerMessage(1, "当前项目已领过");
            cm.dispose();
            return;
        }
        if (rmb < condition[sel]) {
            cm.playerMessage(1, "充值金额没达到要求")
            cm.dispose();
            return;
        }
		if (cm.WeaponLimitBreak(reward[sel][1])) {
			cm.setEventCount("每天破攻礼包" + sel);
        cm.playerMessage(1, "领取成功！");
        cm.worldSpouseMessage(0x05,"※ 破攻享不停 ※" + " : " + "玩家 " + cm.getChar().getName() + " 领到了每日破攻 " + condition[sel] + " 元每日破攻");
		cm.worldSpouseMessage(0x05,"※ 破攻享不停 ※" + " : " + "玩家 " + cm.getChar().getName() + " 领到了每日破攻 " + condition[sel] + " 元每日破攻");
		cm.worldSpouseMessage(0x05,"※ 破攻享不停 ※" + " : " + "玩家 " + cm.getChar().getName() + " 领到了每日破攻 " + condition[sel] + " 元每日破攻");
        cm.dispose();
				return;
			} else {
		//cm.WeaponLimitBreak(reward[sel][1]);
		cm.sendOk("#d对不起，检测到您身上并未装备武器。");
				cm.dispose();
				}

        /*var rewardlist = new Array();
        for (var i = 0; i < reward.length; i++) {
            if (reward[i][0] == sel) {
                rewardlist.push(new Array(reward[i][1], reward[i][2]));
            }
        }
        if (!cm.canHoldSlots(rewardlist.length)) {
            cm.playerMessage(1, "包裹空间不足，请确保包裹每个栏位有至少 " + rewardlist.length + " 格空间");
            cm.dispose();
            return;
        }

		if (cm.getInventory(1).getItem(1) == null || (cm.getInventory(1).getItem(1).getItemId()<1210000 && cm.getInventory(1).getItem(1).getItemId()>1580000)) {
				cm.sendOk("对不起，装备栏第一格没有物品或者不是武器.");
				cm.dispose();
				return;
			}
        for (var i = 0; i < rewardlist.length; i++) {
            //cm.changeitemdamage(rewardlist[i][0]);
			cm.changeitemdamage(1,rewardlist[i][0]);
        }
        cm.setbosslog("每天破攻礼包" + sel);
        cm.playerMessage(1, "领取成功！");
        cm.dropmessage(-5,"※ 破攻享不停 ※" + " : " + "玩家 " + cm.getChar().getName() + " 领到了每日破攻 " + condition[sel - 1] + " 元每日破攻");
        cm.dispose();*/
    }
}
